Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/4060 gantt working hours #5403

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from

Conversation

robo1200
Copy link

📑 Summary

First contribution to the community but a long time user and want to start providing some added benefit. Only a hobbyist developer so apologies in advance if some of this is not right first time.
Updated the Gantt chart to allow workday start and end times to be entered and for the gantt chart to then uses them for calculated task end dates assuming durations in hours and or minutes are provided.

Resolves #4060

📏 Design Decisions

Added options to the parser for a Working day start time and working day end time

Ammended the GetEndDate function to be able to calculate task end dates and times using working hours if provided by the user alongside a task duration. Ensured through testing that other elements of the gantt chart functionality such as inclusive / exclusive weekends can still be used in conjuction

Added applicable tests for both the parser and the ganttDB file.

📋 Tasks

Make sure you

  • [ Y] 📖 have read the contribution guidelines
  • [Y ] 💻 have added necessary unit/e2e tests.
  • [Y ] 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • [Y ] 🔖 targeted develop branch

@github-actions github-actions bot added the Type: Enhancement New feature or request label Mar 22, 2024
Copy link

netlify bot commented Mar 22, 2024

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 97aa491
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/667086102591410008f18387
😎 Deploy Preview https://deploy-preview-5403--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@robo1200
Copy link
Author

robo1200 commented Apr 3, 2024

@sidharthv96
My apologies but I have quite a lot of conflicts with my branch. It this something relating to my request or something that should occur? Happy to make changes if this on me to fix. If so can someone point me in the right direction. thanks :)

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 12 lines in your changes missing coverage. Please review.

Project coverage is 5.87%. Comparing base (d6ccd93) to head (f344cfa).
Report is 2 commits behind head on develop.

Current head f344cfa differs from pull request most recent head 97aa491

Please upload reports for the commit 97aa491 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #5403      +/-   ##
==========================================
+ Coverage     5.73%   5.87%   +0.13%     
==========================================
  Files          278     277       -1     
  Lines        41999   42060      +61     
  Branches       490     524      +34     
==========================================
+ Hits          2409    2470      +61     
  Misses       39590   39590              
Flag Coverage Δ
unit 5.87% <84.21%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/mermaid/src/diagrams/gantt/ganttDb.js 78.06% <84.21%> (+0.58%) ⬆️

... and 1 file with indirect coverage changes

Comment on lines 483 to 492
You can assign core working hours within the Gantt by providing a time value to `wdStartTime` and `wdEndTime`. It expects a time in the 24hour format as shown below.

```gantt
title A Gantt Diagram
accTitle: A simple sample gantt diagram
accDescr: 2 sections with 2 tasks each, from 2014
dateFormat YYYY-MM-DD
wdStartTime 08:00
wdEndTime 17:00
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the YAML config for this, instead of adding more custom syntax?

Suggested change
You can assign core working hours within the Gantt by providing a time value to `wdStartTime` and `wdEndTime`. It expects a time in the 24hour format as shown below.
```gantt
title A Gantt Diagram
accTitle: A simple sample gantt diagram
accDescr: 2 sections with 2 tasks each, from 2014
dateFormat YYYY-MM-DD
wdStartTime 08:00
wdEndTime 17:00
```
You can assign core working hours within the Gantt by providing a time value to `wdStartTime` and `wdEndTime`. It expects a time in the 24hour format as shown below.
```
---
title: A Gantt Diagram
config:
gantt:
dateFormat: YYYY-MM-DD
workdayStartTime: 08:00
workdayEndTime: 17:00
---
gantt
accTitle: A simple sample gantt diagram
accDescr: 2 sections with 2 tasks each, from 2014
```

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry can you explain in a bit more detail what you mean? Does this relate to not using jison?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was to move new configurations into the yaml config section, and not to add more keywords in jison.
I only edited the documentation, to reflect how it'll look after the change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirname
The below is created within the config.type.ts automatically by the YAML config file (wdStartTime and wdEndTime are the two new pieces of code. However, I want to import this into the GanttDB.js file but as i understand it 'interface' is a typescript definition that cannot be imported in a plain JS file. What methods are there for getting around this? Or is it purely a need to re-write the GanttDB file?

export interface GanttDiagramConfig extends BaseDiagramConfig {
  /**
   * Margin top for the text over the diagram
   */
  titleTopMargin?: number;
  /**
   * The height of the bars in the graph
   */
  barHeight?: number;
  /**
   * The margin between the different activities in the gantt diagram
   */
  barGap?: number;
  /**
   * Margin between title and gantt diagram and between axis and gantt diagram.
   *
   */
  topPadding?: number;
  /**
   * The space allocated for the section name to the right of the activities
   *
   */
  rightPadding?: number;
  /**
   * The space allocated for the section name to the left of the activities
   *
   */
  leftPadding?: number;
  /**
   * Vertical starting position of the grid lines
   */
  gridLineStartPadding?: number;
  /**
   * Font size
   */
  fontSize?: number;
  /**
   * Font size for sections
   */
  sectionFontSize?: string | number;
  /**
   * The number of alternating section styles
   */
  numberSectionStyles?: number;
  /**
   * Date/time format of the axis
   *
   * This might need adjustment to match your locale and preferences.
   *
   */
  axisFormat?: string;
  /**
   * axis ticks
   *
   * Pattern is:
   *
   * ```javascript
   * /^([1-9][0-9]*)(millisecond|second|minute|hour|day|week|month)$/
   * ```
   *
   */
  tickInterval?: string;
  /**
   * When this flag is set, date labels will be added to the top of the chart
   *
   */
  topAxis?: boolean;
  /**
   * Controls the display mode.
   *
   */
  displayMode?: '' | 'compact';
  /**
   * On which day a week-based interval should start
   *
   */
  weekday?: 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
  /**
   * Allows user to set the start time for the Workday. Used in calculating end times for tasks when set in hours
   *
   */
  wdStartTime?: string;
  /**
   * Allows user to set the end time for workday
   *
   */
  wdEndTime?: string;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure Gantt diagram to use specific day hours
2 participants